home *** CD-ROM | disk | FTP | other *** search
- TEndApp Component
-
- by
-
- Dave Nottage
-
- of
-
- ALIEN Computing
- PO Box 45
- CALLINGTON SA 5254
- AUSTRALIA
-
- This component is freeware. Please feel free to distribute in any
- legal manner you wish, as long as you include the following files:
-
- README.TXT (this file, but you already knew that)
- ENDAPP.DCU
- ENDAPP.DCR (It's got the really ace component bitmap. Well, allllrighty then!!!)
-
- I haven't included the source, 'coz someone is bound to vandalize my
- code, and I don't want to be responsible for someone elses mistakes.
- ie If you find a bug with this, it's my fault, so please tell me about it.
- Having said that, I will not take any responsibility for any loss of
- business, pecuniary loss, loss of files, loss of data, loss of hair or
- body parts caused by this component.
-
- If you want to tell me something, and don't like snail mail, send something
- on comp.lang.pascal.delphi.components. I read the newsgroup fairly often, and don't
- have my own personal 'net mail account yet. (I've gotta get one soon!!!!).
-
- Enough of that, now about the component!!!!!!!
-
- TEndApp makes it easier to trap those annoying messages that your Delphi
- app would otherwise miss, specifically when some wally closes Windows down without
- saving their work.
-
- Its only properties are Name and Tag.
-
- It's power lies in its two events:
-
- OnQueryEndSession traps the WM_QUERYENDSESSION message that Windows sends
- all applications when Windows wants to close down. OnQueryEndSession passes a boolean
- parameter called OKEnd, which is initially set to False. If you really want your app
- to end, set it to True eg:
-
- procedure TForm1.EndApp1QueryEndSession(var OKEnd:boolean);
- begin
- if FileIsntSavedYet then
- if MessageDlg('Windows is shutting down & you havent saved!'#13
- 'Yes=Save and Exit, No=Stop this insanity',
- mtConfirmation,[mbYesNo],0)=mrYes then
- begin
- SaveBeforeItsTooLate;
- OKEnd:=True { Bite the bullet and agree to close down }
- end
- else
- OKEnd:=False { No, go away, I'm not ready }
- end;
-
- OnEndSession traps the WM_ENDSESSION message, which is sent after WM_QUERYENDSESSION.
- The boolean parameter Ending tells you whether or not all apps agreed to shut down. eg:
-
- procedure TForm1.EndApp1EndSession(Ending:boolean);
- begin
- if Ending then
- { Too late now... }
- SaveWithoutAskingBecauseItsEndingAnyway
- end;
-
- This component is a result of queries vented on numerous newsgroups, mail lists,
- street corners etc. I hope you find it as satisfying as I did when I got the damn thing
- to work.
-
- Install the component in the usual way, or the unusual way if you can find one. To
- alleviate tab overpopulation, the component installs on the 'Samples' palette.
- What...you mean you've already got 1001 components on your 'Samples' palette? Oh, well..
-
-